cmake_minimum_required(VERSION 3.8)
project(hello_ros2)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# Find dependencies
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

# Find OpenCV
find_package(OpenCV REQUIRED)
find_package(cv_bridge REQUIRED)

# Create talker node
add_executable(talker src/talker.cpp)
ament_target_dependencies(talker rclcpp std_msgs)

# Create listener node
add_executable(listener src/listener.cpp)
ament_target_dependencies(listener rclcpp std_msgs cv_bridge)
target_link_libraries(listener ${OpenCV_LIBS} cv_bridge::cv_bridge)

# Install executables
install(TARGETS
  talker
  listener
  DESTINATION lib/${PROJECT_NAME}
)

# Install launch files
install(DIRECTORY launch
  DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()